package com;

import java.io.IOException;
import java.sql.ResultSet;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import dao.DBManipulation;

/**
 * Servlet implementation class SalesVoucherServlet
 */
public class SalesVoucherServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public SalesVoucherServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
				try
				{
				System.out.println("In Sales Voucher Servlet");
		
				SalesUserBean user1 = new SalesUserBean(); 
				user1.setSalesOrderNumber(request.getParameter("ordnum")); 
				user1.setInvoiceNumber(request.getParameter("Innum")); 
				user1.setSalesDate(request.getParameter("dte")); 
				user1.setCustomerName(request.getParameter("custname")); 
				user1.setCustomerCode(request.getParameter("custcode")); 
				user1.setCustomerInvoiceNumber(request.getParameter("custinnum")); 
				user1.setProductName(request.getParameter("prodname")); 
				user1.setProductQuantity(Integer.parseInt(request.getParameter("prodquantity")));
				user1.setProductRate(Double.parseDouble(request.getParameter("prodrate"))); 
    
				user1.setNetAmount(Double.parseDouble(request.getParameter("netamount"))); 
				user1.setTaxationCategory(Double.parseDouble(request.getParameter("taxcat"))); 
				
				user1.setTaxAmount(Double.parseDouble(request.getParameter("taxamount"))); 
				user1.setTransportCharges(Double.parseDouble(request.getParameter("transport"))); 
				user1.setTotalAmount(Double.parseDouble(request.getParameter("totalamount"))); 
				user1.setCreditLimit(Integer.parseInt(request.getParameter("credlimit"))); 

				DBManipulation dbc= new DBManipulation();
				dbc.insertSalesVoucher(user1);
				}
				catch(Exception e)
				{
					e.printStackTrace();
				}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}
	
	

}
